<div class="main-content">
    <!-- #section:basics/content.breadcrumbs -->
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb"><li>
                <i class="ace-icon fa fa-th-large th-large-icon"></i> 统一管理 <i class="ace-icon fa fa-angle-double-right"></i> 订单列表
            </li></ul><!-- /.breadcrumb -->
    </div>

    <!-- /section:basics/content.breadcrumbs -->
    <div class="page-content">
        <!-- #section:settings.box -->
        <div class="ace-settings-container" id="ace-settings-container" style="margin-top:-48px;">
            <div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
                <i class="ace-icon fa fa-cog bigger-150"></i>
            </div>
            <div class="ace-settings-box clearfix" id="ace-settings-box">
                <div class="pull-left width-50">
                    <!-- #section:settings.skins -->
                    <div class="ace-settings-item">
                        <div class="pull-left">
                            <select id="skin-colorpicker" class="hide">
                                <option data-skin="no-skin" value="#438EB9" <?= !isset($_COOKIE['ace_skin']) || $_COOKIE['ace_skin'] != 'no-skin' ? 'selected' : '' ?> >#438EB9</option>
                                <option data-skin="skin-1" value="#222A2D" <?= isset($_COOKIE['ace_skin']) && $_COOKIE['ace_skin'] == 'skin-1' ? 'selected' : '' ?> >#222A2D</option>
                                <option data-skin="skin-2" value="#C6487E" <?= isset($_COOKIE['ace_skin']) && $_COOKIE['ace_skin'] == 'skin-2' ? 'selected' : '' ?> >#C6487E</option>
                                <option data-skin="skin-3" value="#D0D0D0" <?= isset($_COOKIE['ace_skin']) && $_COOKIE['ace_skin'] == 'skin-3' ? 'selected' : '' ?> >#D0D0D0</option>
                            </select>
                        </div>
                        <span>&nbsp;肤色切换</span>
                    </div>

                    <!-- /section:settings.skins -->

                    <!-- #section:settings.navbar -->
                    <div class="ace-settings-item">
                        <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-navbar" />
                        <label class="lbl" for="ace-settings-navbar">&nbsp; 固定导航</label>
                    </div>

                    <!-- /section:settings.navbar -->

                    <!-- #section:settings.sidebar -->
                    <div class="ace-settings-item">
                        <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-sidebar" />
                        <label class="lbl" for="ace-settings-sidebar">&nbsp; 固定菜单栏</label>
                    </div>
                    <!-- /section:settings.sidebar -->

                    <!-- #section:settings.container -->
                    <div class="ace-settings-item">
                        <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-add-container" />
                        <label class="lbl" for="ace-settings-add-container">&nbsp; 宽窄屏切换</label>
                    </div>
                    <!-- /section:settings.container -->
                </div><!-- /.pull-left -->

                <div class="pull-left width-50">
                    <!-- #section:basics/sidebar.options -->
                    <div class="ace-settings-item">
                        <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-hover" />
                        <label class="lbl" for="ace-settings-hover">&nbsp; 内级栏目切换</label>
                    </div>

                    <div class="ace-settings-item">
                        <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-compact" />
                        <label class="lbl" for="ace-settings-compact">&nbsp; 菜单栏切换</label>
                    </div>

                    <div class="ace-settings-item">
                        <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-highlight" />
                        <label class="lbl" for="ace-settings-highlight">&nbsp; 当前菜单凸显</label>
                    </div>
                    <!-- /section:basics/sidebar.options -->
                </div><!-- /.pull-left -->
            </div><!-- /.ace-settings-box -->
        </div><!-- /.ace-settings-container -->

        <!-- /section:settings.box -->
        <div class="page-content-area">
            <div class="row">
                <div class="col-xs-12">
					<link rel="stylesheet" href="/public/assets/css/datepicker.css" />
					<script src="/public/assets/js/date-time/bootstrap-datepicker.min.js"></script>
					<script src="/public/assets/js/date-time/daterangepicker.min.js"></script>
					<script src="/public/assets/js/date-time/moment.min.js"></script>
					<script src="/public/assets/js/date-time/locales/bootstrap-datepicker.zh-CN.js"></script>
					<div class="form-group">
						<form class="form-horizontal" role="form" action="" method="get">
							<div class="col-md-3 col-sm-5" style="margin-bottom:10px;height:30px;">
								<label style="margin-top:10px;"><input name="step" type="radio" value="1" <?=$step==1?'checked':''?> class="ace" checked><span class="lbl"> 预定</span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<label style="margin-top:10px;"><input name="step" type="radio" value="2" <?=$step==2?'checked':''?> class="ace"><span class="lbl"> 入住</span></label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<label style="margin-top:10px;"><input name="step" type="radio" value="3" <?=$step==3?'checked':''?> class="ace"><span class="lbl"> 离店</span></label>
							</div>
							<div class="col-md-3 col-sm-5" style="margin-bottom:10px;">
								<div class="input-daterange input-group">
									<input type="text" class="input-md form-control" name="start" value="<?= $start ?>" placeholder="开始时间" data-rel="tooltip" title="开始时间"/>
									<span class="input-group-addon"><i class="fa fa-exchange"></i></span>
									<input type="text" class="input-md form-control" name="end" value="<?= $end ?>" placeholder="结束时间" data-rel="tooltip" title="结束时间"/>
								</div>
							</div>
							<div class="col-md-2 col-sm-3 col-xs-6" style="margin-bottom:10px;">
								<input type="text" name="orderId" value="<?=$orderId?>" placeholder="订单号" data-rel="tooltip" title="" data-original-title="订单号">
							</div>
							<div class="col-md-2 col-sm-3 col-xs-6" style="margin-bottom:10px;">
								<input type="text" name="hotelName" value="<?=$hotelName?>" placeholder="酒店名称" data-rel="tooltip" title="" data-original-title="酒店名称">
							</div>
							<div class="col-md-2 col-sm-3 col-xs-6" style="margin-bottom:10px;">
								<input type="text" name="uname" value="<?=$uname?>" placeholder="入住人" data-rel="tooltip" title="" data-original-title="入住人">
							</div>
							<div class="col-md-2 col-sm-3 col-xs-6" style="margin-bottom:10px;">
								<input type="text" name="qmorderId" value="<?=$qmorderId?>" placeholder="青芒果订单号" data-rel="tooltip" title="" data-original-title="青芒果订单号">
							</div>
							<div class="col-md-2 col-sm-3 col-xs-6" style="margin-bottom:10px;">
								<select class="form-control" name="chann" placeholder="渠道" data-rel="tooltip" title="渠道" style="max-width:210px;">
									<option value="0">全部</option>
									<?
									foreach($channels as $k=>$v){
										?><option value="<?=$v['osiiid']?>" <?=$chann&&$chann==$v['osiiid']?'selected':''?>><?=$v['title']?></option><?
									}
									?>
								</select>
							</div>
							<div class="col-md-1 col-sm-2 col-xs-3" style="margin-bottom:10px;">
								<button class="btn btn-info btn-sm" data-rel="tooltip" title="搜索"><i class="ace-icon fa fa-search"></i>搜索</button>
							</div>
						</form>
						<div class="col-md-1 col-sm-2 col-xs-3" style="margin-bottom:10px;">
							<a href="<?=$this->url('unify/texport?step='.$step.'&start='.$start.'&end='.$end.'&orderId='.$orderId.'&hotelName='.$hotelName.'&uname='.$uname.'&qmorderId='.$qmorderId.'&chann='.$chann)?>"><button class="btn btn-sm" data-rel="tooltip" title="导出"><i class="ace-icon fa fa-share"></i>导出</button></a>
						</div>
					</div>
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>订单号</th>
                                    <th>青芒果订单号</th>
                                    <th>渠道</th>
                                    <th width="170px">酒店名称</th>
                                    <th width="115px">房型名称</th>
                                    <th width="130px">入住人</th>
                                    <th>电话</th>
                                    <th>入住时间段</th>
                                    <th>订单金额/佣金(元)</th>
                                    <th>间/夜</th>
                                    <th>状态</th>
                                    <th>下单时间</th>
                                    <th width="150px">备注</th>
                                    <th width="156px">操作</th>
                                </tr>
                            </thead>

                            <tbody>
                                <?
                                if($re){
                                foreach($re as $k=>$v){?>
                                <tr>
                                    <td><?= $v['orderId'] ?></td>
                                    <td><?= $v['qmorderId'] ?></td>
                                    <td><?= $v['chanName'] ?></td>
                                    <td><?= $v['hotelName'] ?></td>
                                    <td><?= $v['title'] ?></td>
                                    <td><?= $v['name'] ?></td>
                                    <td><?= $v['mobile'] ?></td>
                                    <td><?= $v['startDate'] ?> / <?= $v['endDate'] ?></td>
                                    <td><?= $v['price'] ?> / <?= $v['commission'] ?></td>
                                    <td><?= $v['countRoom'] ?> / <?= (strtotime($v['endDate']) - strtotime($v['startDate'])) / 24 / 3600 ?></td>
                                    <td><?= $myconfigs['status'][$v['status']] ?></td>
                                    <td><?= $v['created'] ?></td>
                                    <td class="ra"><?= $v['remark'] ?></td>
                                    <td>
										<button class="btn btn-info btn-xs pull-left" style="margin-right:10px;margin-bottom:5px;" data-rel="tooltip" title="" onclick="upRemark('<?=$v['id']?>','<?=$k?>')" data-original-title="修改备注">修改备注</button>
										<?if($v['status']==1){?><button class="btn btn-info btn-xs pull-left" data-rel="tooltip" title="" onclick="CancelHotelOrder('<?=$v['id']?>',this)" data-original-title="取消订单">取消订单</button><?}?>
									</td>
                                </tr>
                                <?}
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                    <?= $pageHtml ?>
                </div>
            </div>
        </div><!-- /.page-content-area -->
    </div><!-- /.page-content -->
</div><!-- /.main-content -->
<!-- inline scripts related to this page -->

<div class="bootbox modal fade bootbox-prompt in" tabindex="-1" role="dialog" aria-hidden="false" id="accountForm" style="position:absolute;display:block;left:100%;">
	<div style="background-color: #303030;filter:alpha(opacity=70);-moz-opacity:0.7;-khtml-opacity: 0.7;opacity: 0.7;position: fixed;width: 100%;height: 100%;"></div>
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="bootbox-close-button close" data-dismiss="modal" aria-hidden="true" onclick="animateColse('#accountForm')">×</button>
				<h4 class="modal-title">修改备注（禁止特殊字符）</h4>
			</div>
			<form class="bootbox-form" id="potTal">
				<div class="modal-body">
					<div class="bootbox-body">
						<input type="hidden" name="kid" value="0" />
						<textarea style="width:100%;height:100px;resize:none;" name="remark"></textarea>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary btn-sm" onclick="potTal()">确认修改</button>
				</div>
			</form>
		</div>
	</div>
</div>

<script type="text/javascript">
$('.input-daterange').datepicker({
	autoclose: true,
	format: 'yyyy-mm-dd',
	language: "zh-CN",
	todayBtn: true,
	todayHighlight: true,
	startDate: ''
});
function CancelHotelOrder(kid,obj){
	if(confirm("确认取消订单？取消后不可更改！")){
		$.ajax({
			type:'post',
			url:"<?=$this->url('unify/CancelHotelOrder')?>",
			data:"kid="+kid,
			dataType:'json',
			timeout: 0,
			beforeSend:function(XMLHttpRequest){
				$(obj).html('取消中...').prop("disabled",true);
			}, 
			success:function (r){
				if(r.state==1){
					gritter("gritter-success gritter-light",10000,"操作提示",r.html);
					setTimeout('window.location.reload()',1000);
				}else if(r.state==0){
					gritter("gritter-error gritter-light",10000,"操作提示",r.html);
				}
				$(obj).html('取消订单').prop("disabled",false);
			},error:function(){
				gritter("gritter-error gritter-light",10000,"操作提示","网络错误！请联系我方工作人员。");
				$(obj).html('取消订单').prop("disabled",false);
			}
		});
	}
}
function upRemark(kid,kar){
	$("#accountForm").animate({left:"0%"});$('#potTal input[name="kid"]').val(kid);
	$('#potTal textarea[name="remark"]').html($('tbody tr:eq('+kar+') td.ra').html());
}
function potTal(){
	if(confirm("确认修改该备注？")){
		$.ajax({
			type:'post',
			url:"<?=$this->url('unify/upRemark')?>",
			data:$('#potTal').serialize(),
			dataType:'json',
			success:function (r){
				if(r.state==1){
					gritter("gritter-success gritter-light",10000,"操作提示",r.html);
					setTimeout('window.location.reload()',2000);
				}else if(r.state==0){
					gritter("gritter-error gritter-light",10000,"操作提示",r.html);
				}
			},error:function(){
			   gritter("gritter-error gritter-light",10000,"操作提示","网络错误！请联系我方工作人员。");
			}
		});
	}
}
</script>